from django.db import models


# Create your models here.
class Student(models.Model):
    # 学号，不允许为空，主键
    sno = models.IntegerField(db_column="SNo", verbose_name="学号",primary_key=True,null=False)
    # 姓名，最长100个字符，不允许为空
    name = models.CharField(
        db_column="SName", max_length=100, verbose_name="学生姓名", null=False
    ) 
    # 性别选项
    GENDER_CHOICES = (
        (1, "男"),
        (2, "女"),
    )
    gender = models.IntegerField(
        db_column="Gender",
        choices=GENDER_CHOICES,
        default=1,
        verbose_name="性别",
        null=True,
        blank=True,
        help_text="性别",
    )
    # 出生日期，不允许为空
    birthday = models.DateField(
        db_column="Birthday", null=False,verbose_name="出生日期",
    )  
    # 手机号码
    mobile = models.CharField(db_column="Mobile", verbose_name="手机",max_length=100)
    # 邮箱地址
    email = models.CharField(db_column="Email",verbose_name="邮箱", max_length=100)  
    # 家庭住址
    address = models.CharField(db_column="Address",verbose_name="家庭住址", max_length=200)
    # 照片
    image = models.CharField(db_column="Image", verbose_name="照片",max_length=200, null=True)

    class Meta:
        managed = True
        db_table = "system_students"
        # 数据库表备注
        db_table_comment = "学生信息"
        verbose_name = "学生管理"
        verbose_name_plural = verbose_name
        # 根据id排序
        ordering = ['sno']

    # __str__方法
    def __str__(self):
        return "学号:%s\t姓名:%s\t性别:%s" % (self.sno, self.name, self.gender)
